# coding=utf-8
# ACM模式
# 把logits输入到softmax里面，得到最大值以及序号，需要记住softmax的公式exp(x_i)/sum
# 结果：全过。
import sys
import math
def getRes(logits,cls):
    after_logits = []
    for value in logits:
        after_logits.append(math.exp(value))
    sum_num = sum(after_logits)

    for i in range(len(after_logits)):
        after_logits[i] = after_logits[i] / sum_num
    max_value = max(after_logits)

    for i in range(len(after_logits)):
        if max_value == after_logits[i]:
            index = i
            break
    return [index, max_value]
if __name__ == "__main__":
    # 读取第一行的n
    line = sys.stdin.readline().strip()
    N,K = list(map(int, line.split()))

    values = []
    for i in range(N):
        # 读取每一行
        line = sys.stdin.readline().strip()
        # 把每一行的数字分隔后转化成int列表
        value = list(map(float, line.split()))
        values.append(value)
    res = []
    for value in values:
        res.append(getRes(value,K))
    for content in res:
        print(content[0], "%.6f" % content[1])
    

